package com.payment.ktb.activity.main1;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.activity.BaseActivity;
import com.payment.ktb.activity.MainActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by admin on 2017/9/9.
 */

public class OrderConfirmFailActivity extends BaseActivity {




    @BindView(R.id.tv_orderconfirmfail_amount)
    TextView tv_orderconfirmfail_amount;
    @BindView(R.id.tv_orderconfirmfail_goodsname)
    TextView tv_orderconfirmfail_goodsname;
    @BindView(R.id.tv_orderconfirmfail_bankname)
    TextView tv_orderconfirmfail_bankname;
    @BindView(R.id.tv_orderconfirmfail_bankno)
    TextView tv_orderconfirmfail_bankno;
    @BindView(R.id.tv_orderconfirmfail_orderno)
    TextView tv_orderconfirmfail_orderno;
    @BindView(R.id.tv_orderconfirmfail_ordertime)
    TextView tv_orderconfirmfail_ordertime;
    @BindView(R.id.tv_orderconfirmfail_reason)
    TextView tv_orderconfirmfail_reason;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orderconfirmfail);
        ButterKnife.bind(this);
        initTitle("订单确认");
        hideTitleBack();
        initData();
    }

    private void initData() {
        tv_orderconfirmfail_amount.setText("¥ " + handleFen2Yuan(getIntent().getStringExtra("amount")));
        tv_orderconfirmfail_goodsname.setText(getIntent().getStringExtra("goodsName"));

        if (!TextUtils.isEmpty(getIntent().getStringExtra("goodsName")) && "Vip1".equals(getIntent().getStringExtra("goodsName"))) {
            tv_orderconfirmfail_goodsname.setText("会员购买");
        }else if (!TextUtils.isEmpty(getIntent().getStringExtra("goodsName")) && "Vip2".equals(getIntent().getStringExtra("goodsName"))) {
            tv_orderconfirmfail_goodsname.setText("会员购买");
        }else if (!TextUtils.isEmpty(getIntent().getStringExtra("goodsName")) && "151".equals(getIntent().getStringExtra("goodsName"))) {
            tv_orderconfirmfail_goodsname.setText("后台管理费");
        }

        tv_orderconfirmfail_bankname.setText(getIntent().getStringExtra("cardBank"));
        tv_orderconfirmfail_bankno.setText(getIntent().getStringExtra("cardNo"));
        tv_orderconfirmfail_orderno.setText(getIntent().getStringExtra("orderNo"));
        tv_orderconfirmfail_ordertime.setText(getIntent().getStringExtra("orderTime"));
        tv_orderconfirmfail_ordertime.setText(getIntent().getStringExtra("orderTime"));
        tv_orderconfirmfail_reason.setText("失败原因：" + getIntent().getStringExtra("ordermemo"));
    }

    private String handleFen2Yuan(String fen) {
        if (fen.equals("0")) {
            return "0.00";
        }
        double srcFen = Double.valueOf(fen);
        double roundSrcFen = Math.round(srcFen);
        return String.valueOf(roundSrcFen/100);
    }

    @OnClick({R.id.btn_orderconfirmfail_confirm})
    public void clickEvent(View view) {

        switch (view.getId()) {


            //确定按钮
            case R.id.btn_orderconfirmfail_confirm:
                startActivity(MainActivity.class);
                break;

        }


    }

}
